const Base64 = require('js-base64').Base64

const utils = {
    /**
     * 数据持久化
     */
    localSetItem(key, value) {
        window.localStorage.setItem(Base64.encode(key), Base64.encode(value))
    },
    /**
     * 移除持久化数据
     */
    localRemoveItem(key) {
        window.localStorage.removeItem(Base64.encode(key))
    },

    /**
     * 获取持久化数据
     */
    localGetItem(key) {
        let value = window.localStorage.getItem(Base64.encode(key))
        if (!value) {
            return value
        }
        return Base64.decode(value)
    }


}

export default utils
